home *** CD-ROM | disk | FTP | other *** search
Wrap
// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // // SETUP.CPP // Main file for "MAIN.EXE" Setup Studio sample program // Use with CSETUP.DLL release 2.2. // // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // // This file requires Microsoft Visual C++ Compiler and MFC 2.0 Library. // Warning: You use this product at your own risk! You are responsible for making suitable backups in case it screws up. // You can use this file as a template and you can redistribute programs using this file ( Anyway, distributing // this source code file without the full Unregistered Evaluation Copy of Setup Studio is forbidden ). // // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // // There are 5 classes in this file: // // CSetupApp: The application management // CFirst: A splash dialog box with initialisation management // CMain: The main application window which calls dialog boxes and GoSetup function // CChoice1: To choose path and language // CChoice2: To choose files to install // // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Remark: // nPanelBold... specify italic mode ( not the bold mode ! ) // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------- // Private messages // ---------------------------------------------------------- #define PM_FIRST WM_USER + 0x048 // Message for CFirst Box to start the SetupInitialize #define IDCHANGEPATH 36 // EndDialog value when user want to change the path on Choice2 box // ---------------------------------------------------------- // Include files // ---------------------------------------------------------- #include "stdafx.h" #include <stdlib.h> #include <direct.h> #include "setup.h" #include <csetup.h> #include <ctl3d.h> // ---------------------------------------------------------- // Local functions // ---------------------------------------------------------- BOOL ExtractParameter( LPSTR szCommandLine, LPSTR szBuffer, int position ); // C programmers can use this function to retrieve Command Line parameters #ifdef _DEBUG #undef THIS_FILE static char BASED_CODE THIS_FILE[] = __FILE__; #endif // ---------------------------------------------------------- // Local variables // ---------------------------------------------------------- BOOL bIsSetupOK; // Result of SetupInitialize Function int iLanguage; // Language ( french or English ) CString UserPath; // Destination path int iType; // User configuration = TYPE_VB, TYPE_TCW, TYPE_MFC or TYPE_NONE long UserConfigSize; // The size of the user' s selection static char szOriginalPath[160]; // First command line argument static char szTempSetupPath[160]; // Second command line argument // ---------------------------------------------------------- // Local constants // ---------------------------------------------------------- #define TYPE_VB 0 // Indicate Best path for VB users #define TYPE_TCW 1 // Indicate Best path for TCW users #define TYPE_MFC 2 // Indicate Best path for MFC users #define TYPE_NONE 3 // Normal path must be used /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // I try to make a generic Setup Application... /// // This program can have up to 15 checkboxes and each checkbox is /// /// associated with a section. This program performs basic operations // // like section management, icons installation, winfile association // // and can run an EXE or an HLP file. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ----------------------- General settings ------------------------------------ const CString szYourName = "TEST"; // Put your <szYourName> password here, or TEST if you are not registered const CString szYourPassword = ""; // Put your <szPassword> here or nothing if you are not registered const int iBackgroundPaper = BROSSE_3DCIRCLE; // Choose the brush to use as the background paper, ( BROSSE_* ) const BOOL bBeepMode = TRUE; // True if you want the BEEP mode, FALSE if not const BOOL bVerifyMode = TRUE; // True if you want the VERIFY mode, FALSE if not const CString szProductName = "Setup Studio"; // Name of your works const CString szSetupBoxTitle = "Setup Studio Installation"; // Title of the Copy Dialog Box // ----------------------- General interface settings ------------------------------------ const CString Dialog1Title = "Setup Studio 2.2 (c)"; // Dialog box title for the path and other dialog boxes const CString Dialog2Title = "Setup Studio 2.2 (c) - Installation"; // Dialog box title for the option dialog box const CString Dialog3Title = "Setup Studio 2.2 (c) - Installation"; // Dialog box title for the copy dialog box // ----------------------- Interface settings [PANEL1] ( first panel )------------------------------------ const int iPanel1Bitmap = 0; // Bitmap ID for Panel 1 or 0 to disable it const CString szPanel1Title = "Setup Studio 2.2"; // Panel 1 title or a blank string to disable it const CString szPanel1TitleFont = "Arial"; // Panel 1 title font to use const int iPanel1TitleSize = 52; // Panel 1 title font size to use const COLORREF lPanel1TitleColor = RGB(192,192,192); // Panel 1 title color to use const BOOL bPanel1Title3D = TRUE; // Panel 1 title 3D or not const BOOL bPanel1TitleBold = TRUE; // Panel 1 title bold or not const CString szPanel1Detail = "The Windows Setup programs maker"; // Panel 1 detail or a blank string to disable it const CString szPanel1DetailFont = "Times New Roman"; // Panel 1 detail font to use const int iPanel1DetailSize = 28; // Panel 1 detail font size to use const COLORREF lPanel1DetailColor = RGB(0,128,128); // Panel 1 detail color to use const BOOL bPanel1Detail3D = TRUE; // Panel 1 detail 3D or not const BOOL bPanel1DetailBold = TRUE; // Panel 1 detail bold or not // ----------------------- Interface settings [PANEL2] ( user selects files to install )------------------------------------ const int iPanel2Bitmap = IDB_SETUP2; // Bitmap ID for Panel 2 or 0 to disable it const CString szPanel2Title = "Setup Studio 2.2"; // Panel 2 title or a blank string to disable it const CString szPanel2TitleFont = "Arial"; // Panel 2 title font to use const int iPanel2TitleSize = 52; // Panel 2 title font size to use const COLORREF lPanel2TitleColor = RGB(192,192,192); // Panel 2 title color to use const BOOL bPanel2Title3D = TRUE; // Panel 2 title 3D or not const BOOL bPanel2TitleBold = TRUE; // Panel 2 title bold or not const CString szPanel2Detail = "Setup Studio 2.2"; // Panel 2 detail or a blank string to disable it const CString szPanel2DetailFont = "Arial"; // Panel 2 detail font to use const int iPanel2DetailSize = 24; // Panel 2 detail font size to use const COLORREF lPanel2DetailColor = RGB(192,192,192); // Panel 2 detail color to use const BOOL bPanel2Detail3D = TRUE; // Panel 2 detail 3D or not const BOOL bPanel2DetailBold = TRUE; // Panel 2 detail bold or not // ----------------------- Interface settings [PANEL3] ( files transfert )------------------------------------ const int iPanel3Bitmap = 0; // Bitmap ID for Panel 3 or 0 to disable it const CString szPanel3Title = "Setup Studio 2.2"; // Panel 3 title or a blank string to disable it const CString szPanel3TitleFont = "Arial"; // Panel 3 title font to use const int iPanel3TitleSize = 52; // Panel 3 title font size to use const COLORREF lPanel3TitleColor = RGB(255,0,0); // Panel 3 title color to use const BOOL bPanel3Title3D = TRUE; // Panel 3 title 3D or not const BOOL bPanel3TitleBold = TRUE; // Panel 3 title bold or not const CString szPanel3Detail = "[] Just 3 functions required,\n[] No need to learn another language,\n[] Up to 1200 files, 30 diskettes, 40 groups,\n[] Built in ZIP support,\n[] Files larger than a media supported,\ \n[] Files date checking, automatic backup,\n[] Shared DLLs and VBX support,\n[] Multi projects management, \n[] Files are automatically renamed,\n[] SDK Setup Toolkit compatability,\ \n[] French and English mode,\n[] All tools are integrated and provided,\n[] And much much more..."; // Panel 3 detail or a blank string to disable it const CString szPanel3DetailFont = "Arial"; // Panel 3 detail font to use const int iPanel3DetailSize = 22; // Panel 3 detail font size to use const COLORREF lPanel3DetailColor = RGB(0,0,128); // Panel 3 detail color to use const BOOL bPanel3Detail3D = TRUE; // Panel 3 detail 3D or not const BOOL bPanel3DetailBold = FALSE; // Panel 3 detail bold or not // ----------------------- Shared files settings ------------------------------------ const BOOL bUseSharedBatch = FALSE; // Set this to TRUE if you wish to use the shared batch mode const CString szBatchFile = ""; // Dir and Name for the batch file, default = SYSSETUP.TMP\\SYSSETUP.BAT const CString szBatchDir = ""; // Temporary dir for shared files, default = SYSSETUP.TMP with final slash // ----------------------- LOG file settings ------------------------------------ const BOOL bUseLogFile = TRUE; // TRUE if you wish to use a LOG file, FALSE if not. const CString szLogFileName = "SETUP.LOG"; // Log file name ( without dir specification ) // ----------------------- SECTIONS management ------------------------------------ // 1 Section is associated to 1 checkbox typedef struct sSectionEntry{ unsigned bSelected : 1; // ---> TRUE if the user selects this section, FALSE if not long lSize; // ---> Section Size ( in bytes ) CString Name; // ---> Section name ( from SETUP.INF ) CString Directory; // ---> Destination relative directory for the section ( DIRX\\ for example ) CString ELabel; // ---> English label for the section ( will be associated with a CHECKBOX ) CString FLabel; // ---> French Label for the section ( will be associated with a CHECKBOX ) }SSECTIONENTRY; const int NumberOfSections = 6; // From 1 to 8 sections ( and checkboxes ) SSECTIONENTRY far Section[ NumberOfSections]; // Now it' s depend of your INF File: You must create section entries for all checkboxes you want and // you must respect the diskettes order if your setup program contains more than 1 diskette: // See InitInstance for Implementation // ----------------------- Icons management ------------------------------------ const BOOL bInstallIcons = TRUE; // Install icons if section 0 is selected typedef struct sIconEntry { CString szIconRelativeName; // Program name for specified icon ( CTL3D\\SSTUDIO.EXE for example ) CString EGroupName; // Group Name ( english ) CString EIconName; // Icon title ( english ) CString EIconText; // Icon description ( english ) --> "" to add this icon without any dialog box CString FGroupName; // Group Name ( french ) CString FIconName; // Icon title ( french ) CString FIconText; // Icon description ( french ) }ICONENTRY; const int NumberOfIcons = 2; // How many icons ICONENTRY far IconEntry[NumberOfIcons]; // See InitInstance for Implementation // ----------------------- Association management ------------------------------------ const BOOL bMakeAssociation = TRUE; // TRUE if you wish to create or change WinFile associations typedef struct sWFAsso { CString szProgName; // EXE file name ( with the relative path if any ) CString szExt; // File extension to create ( TXT, DOC ... ) }SWFASSO; const int NumberOfAsso = 1; // Set the number of associations to create SWFASSO far WFAsso[ NumberOfAsso]; // See InitInstance for Implementation // ----------------------- Last step: we launch something ------------------------------------ const CString szLaunch = "SSTUDIO.HLP"; // Give a HLP or an EXE, COM, PIF, BAT file to launch when the setup is ok /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // End of generic declarations. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Implementation - Specific ( so change this ) // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ---------------------------------------------------------- // Constructor // ---------------------------------------------------------- CSetupApp::CSetupApp() { // Now it' s depend of your INF File: You must create section entries for all checkboxes you want and // you must respect the diskettes order if your setup program contains more than 1 diskette: Section[0].Name = "CSetup"; // no directory specification because we use the main destination directory Section[0].ELabel = "&Setup Studio 2.2"; Section[0].FLabel = "&Setup Studio 2.2"; Section[1].Name = "Basic"; Section[1].ELabel = "&Basic header file"; Section[1].FLabel = "Fichier include en &basic"; Section[2].Name = "Help"; Section[2].ELabel = "&Help file"; Section[2].FLabel = "&Documentation"; Section[3].Name = "Wizard"; Section[3].ELabel = "Setup Studio &Wizard"; Section[3].FLabel = "&Assistant"; Section[4].Name = "CTL3D"; Section[4].Directory = "CTL3D\\"; Section[4].ELabel = "CTL &3D API"; Section[4].FLabel = "API CTL &3D"; Section[5].Name = "Demo"; Section[5].Directory = "SAMPLE\\"; Section[5].ELabel = "Sample &program"; Section[5].FLabel = "&Exemple"; IconEntry[0].szIconRelativeName = "SSTUDIO.EXE"; // Icon name ( will be transformed into UserPath + Name ) IconEntry[0].EGroupName = "Setup Studio 2.2"; IconEntry[0].EIconName = "Setup Studio Wizard"; IconEntry[0].EIconText = "Setup Studio Wizard is an utility program to manage files and to create diskettes sets. This new release integrates ZIP support and a files manager."; IconEntry[0].FGroupName = "Setup Studio 2.2"; IconEntry[0].FIconName = "Assistant Setup Studio"; IconEntry[0].FIconText = "Le Wizard est un assistant pour gΘrer les fichiers et crΘer les disquettes du programme. Cette nouvelle version supporte les fichiers ZIP et intΘgre un gestionnaire de fichiers."; IconEntry[1].szIconRelativeName = "SSTUDIO.HLP"; // Icon name ( will be transformed into UserPath + Name ) IconEntry[1].EGroupName = "Setup Studio 2.2"; IconEntry[1].EIconName = "Setup Studio Help"; IconEntry[1].EIconText = "This 140 pages help file contains all necessary informations to build setup programs and to use Setup Studio functions."; IconEntry[1].FGroupName = "Setup Studio 2.2"; IconEntry[1].FIconName ="Aide Setup Studio"; IconEntry[1].FIconText = "Ce fichier d' aide de 140 pages ( en franτais ) contient toutes les informations nΘcessaires pour crΘer des programmes d' installation et pour utiliser les fonctions de Setup Studio."; WFAsso[0].szProgName = "SSTUDIO.EXE"; WFAsso[0].szExt = "CFG"; } // ---------------------------------------------------------- // WM_INITDIALOG // Guess the best path for user // ---------------------------------------------------------- BOOL CChoice1::OnInitDialog() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// CDialog::OnInitDialog(); CString TempVBPath; register int i=0; SetWindowText( Dialog2Title ); // We change the font weight if ((hfontDlg = (HFONT) SendMessage(WM_GETFONT) )) { if (::GetObject(hfontDlg, sizeof(LOGFONT), (LPSTR) &lFont)) { lFont.lfWeight = FW_NORMAL; if (hfontDlg = CreateFontIndirect((LPLOGFONT) &lFont)) { SendDlgItemMessage( IDC_EDITSRCPATH, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_GROUPLANGUAGE, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_RADIOENGLISH, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_RADIOFRENCH, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_TEXTE, WM_SETFONT, (WPARAM) hfontDlg, 0); } } } SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) ); Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL ); CenterDialogBox( m_hWnd ); CString ProductName; ProductName = ( iLanguage == LANGUAGE_FRENCH )? "Indiquer le rΘpertoire ou vous souhaitez installer ": "Please, give the directory in which you want to install "; ProductName += szProductName; ProductName += ( iLanguage == LANGUAGE_FRENCH )?" et cliquer sur OK:":" and click on OK"; CheckRadioButton( IDC_RADIOENGLISH, IDC_RADIOFRENCH, ( iLanguage == LANGUAGE_FRENCH )?IDC_RADIOFRENCH: IDC_RADIOENGLISH ); SetDlgItemText( IDC_GROUPLANGUAGE, ( iLanguage == LANGUAGE_FRENCH )? "Votre langage " : "Your language "); SetDlgItemText( IDC_TEXTE, ProductName ); SetDlgItemText( IDCANCEL, ( iLanguage == LANGUAGE_FRENCH )?"&Abandonner":"&Abort"); /////////////////////////////////////////////////////////// Specific ////////////////////////////////////////////////////////////////////// if ( UserPath.GetLength() > 0 ) SetDlgItemText( IDC_EDITSRCPATH, UserPath ); else { if ( DoesFileExist( "VB.INI", FALSE) ) { TempVBPath = GetWinFileAssociation( "FRM" ) ; if ( TempVBPath.GetLength() > 0 ) { TempVBPath = TempVBPath.Left( TempVBPath.GetLength() - 5 ); // kill VB.EXE TempVBPath += "SSETUP"; TempVBPath = FormatFileNameValid( TempVBPath, TRUE ); TempVBPath.MakeUpper(); UserPath = TempVBPath ; iType = TYPE_VB; } } if ( DoesFileExist( "TCW.INI", FALSE) ) { TempVBPath = GetWinFileAssociation( "PRJ" ) ; if ( TempVBPath.GetLength() > 0 ) { TempVBPath = TempVBPath.Left( TempVBPath.GetLength() - 10 ); // kill BIN\\TCW.EXE TempVBPath += "SSETUP" ; TempVBPath = FormatFileNameValid( TempVBPath, TRUE ) ; TempVBPath.MakeUpper(); UserPath = TempVBPath ; iType = TYPE_TCW; } } if ( DoesFileExist( "AUTOEXEC.BAT", FALSE) ) { GetPrivateProfileString( "Microsoft Visual C++", "Path1", "", TempVBPath.GetBuffer(100), 98, "MSVC.INI"); TempVBPath.ReleaseBuffer(); if ( TempVBPath.GetLength() > 0 ) { TempVBPath = TempVBPath.Left( TempVBPath.GetLength() - 3 ); // kill BIN TempVBPath += "SSETUP"; TempVBPath = FormatFileNameValid( TempVBPath, TRUE ); TempVBPath.MakeUpper(); UserPath = TempVBPath ; iType = TYPE_MFC; } } if ( UserPath.GetLength() < 1 ) { GetWindowsDirectory( UserPath.GetBuffer(180), 178 ); UserPath.ReleaseBuffer(); UserPath = UserPath.Left( 3 ); UserPath += "SSETUP\\" ; iType = TYPE_NONE; } SetDlgItemText( IDC_EDITSRCPATH, UserPath ); /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// for ( i = 0 ; i < NumberOfSections ; i++ ) { if ( Section[i].Name.GetLength()> 0 ) Section[i].lSize = GetSectionSize( Section[i].Name ); } /////////////////////////////////////////////////////////// Specific ////////////////////////////////////////////////////////////////////// Section[0].bSelected = TRUE; Section[1].bSelected = (iType == TYPE_VB)?TRUE:FALSE; Section[2].bSelected = TRUE; Section[3].bSelected = TRUE; Section[4].bSelected = TRUE; Section[5].bSelected = TRUE; } (CEdit*)(GetDlgItem( IDC_EDITSRCPATH))->SetFocus(); ((CEdit*)(GetDlgItem( IDC_EDITSRCPATH)))->SetSel( 0, -1L ); return FALSE; // return TRUE unless you set the focus to a control } // ---------------------------------------------------------- // CMain::PM_FIRST // Main function // ---------------------------------------------------------- afx_msg LRESULT CMain::OnFirstPrivate( WPARAM wParam, LPARAM lParam ) { CChoice1 box1( this ); // path selection CChoice2 box2( this ); // options selection int test2, iResult; register int i = 0; CString szLogFile; CString SrcHelpFile, DestHelpFile, Message,TempPath; /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// FIRSTBOX: if ( box1.DoModal() == IDCANCEL ) { if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"Etes vous certain de vouloir\nabandonner l' installation?": "Are you sure you wish to abort\nthe installation program?", Dialog1Title, MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION ) == IDYES ) goto END; else goto FIRSTBOX; } SECONDBOX: // ----- Put Panel 2 if necessary ----- if ( iPanel2Bitmap == 0 ) { if ( szPanel2Title.GetLength() > 0 ) { SetTextLogo( szPanel2Title, szPanel2TitleFont, iPanel2TitleSize, lPanel2TitleColor, bPanel2Title3D, bPanel2TitleBold ); if ( szPanel2Detail.GetLength() > 0 ) SetTextDetail( szPanel2Detail, szPanel2DetailFont, iPanel2DetailSize, lPanel2DetailColor, bPanel2Detail3D, bPanel2DetailBold ); SetLogoType( TRUE ); SendMessage( WM_PAINT ); } } else { SetLogo( AfxGetInstanceHandle(), iPanel2Bitmap ); SetLogoType( FALSE ); SendMessage( WM_PAINT ); } test2 = box2.DoModal(); if ( test2 == IDCANCEL ) { if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"Etes vous certain de vouloir\nabandonner l' installation?": "Are you sure you wish to abort\nthe installation program?", Dialog1Title, MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION ) == IDYES ) goto END; goto SECONDBOX; } else if ( test2 == IDCHANGEPATH ) goto FIRSTBOX; // ----- Put Panel 3 if necessary ----- if ( iPanel3Bitmap == 0 ) { if ( szPanel3Title.GetLength() > 0 ) { SetTextLogo( szPanel3Title, szPanel3TitleFont, iPanel3TitleSize, lPanel3TitleColor, bPanel3Title3D, bPanel3TitleBold ); if ( szPanel3Detail.GetLength() > 0 ) SetTextDetail( szPanel3Detail, szPanel3DetailFont, iPanel3DetailSize, lPanel3DetailColor, bPanel3Detail3D, bPanel3DetailBold ); SetLogoType( TRUE ); SendMessage( WM_PAINT ); } } else { SetLogo( AfxGetInstanceHandle(), iPanel3Bitmap ); SetLogoType( FALSE ); SendMessage( WM_PAINT ); } // log file ------ if ( bUseLogFile ) { szLogFile = UserPath + szLogFileName; SetLogFile( szLogFile ); } // Select sections for ( i = 0 ; i < NumberOfSections ; i++ ) { if ( Section[i].bSelected ) { if ( Section[i].Directory.GetLength() > 0 ) TempPath = UserPath + Section[i].Directory; else TempPath = UserPath; AddSectionToCopyList( Section[i].Name, TempPath ); } } iResult = GoSetup( m_hWnd, TRUE ); // TRUE specifie we will use FINISH.EXE to clean up the temp dir when setup is complete /////////////////////////////////////////////////////////// Specific ////////////////////////////////////////////////////////////////////// if ( iResult == SETUP_SUCCESSFUL ) { SrcHelpFile = UserPath; SrcHelpFile += ( iLanguage == LANGUAGE_FRENCH )? "FRSTUDIO.HLP" : "USSTUDIO.HLP"; DestHelpFile = UserPath + "SSTUDIO.HLP"; if ( DoesFileExist( SrcHelpFile, TRUE ) ) { if ( DoesFileExist( DestHelpFile, TRUE ) ) DeleteFile( DestHelpFile ); RenameFile( SrcHelpFile, DestHelpFile ); } SrcHelpFile = UserPath; SrcHelpFile += ( iLanguage == LANGUAGE_FRENCH )? "USSTUDIO.HLP" : "FRSTUDIO.HLP"; if ( DoesFileExist( SrcHelpFile, TRUE ) ) DeleteFile( SrcHelpFile ); /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// if ( Section[0].bSelected ) { if ( bInstallIcons ) { Message = ( iLanguage == LANGUAGE_FRENCH )?"Souhaitez vous installer les icones de ":"Do you wish to install "; Message += szProductName; Message += ( iLanguage == LANGUAGE_FRENCH )?"?":" icons?"; if ( MessageBox( Message, Dialog1Title, MB_YESNO | MB_ICONQUESTION) == IDYES ) { CString IconPath; for ( i = 0 ; i < NumberOfIcons ; i++ ) { IconPath = UserPath + IconEntry[i].szIconRelativeName; if ( DoesFileExist( IconPath, TRUE ) ) { if ( IconEntry[i].EIconText.GetLength() > 0 ) { AddItemToProgman( ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName, IconPath, ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FIconName : IconEntry[i].EIconName, ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FIconText : IconEntry[i].EIconText ); ShowProgmanGroup( ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName ); } else { AddProgmanGroup(( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName); ShowProgmanGroup( ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName ); AddProgmanItem( IconPath, ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FIconName : IconEntry[i].EIconName ); } } } ShowWindow(SW_SHOWNORMAL ); } } } /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// if ( bMakeAssociation ) { for ( i = 0; i < NumberOfAsso; i++ ) { DestHelpFile = UserPath + WFAsso[i].szProgName; if ( DoesFileExist( DestHelpFile, TRUE )) CreateWinFileAssociation( WFAsso[i].szExt, DestHelpFile ); } } if ( szLaunch != "" ) { DestHelpFile = szLaunch; DestHelpFile = DestHelpFile.Right( 3 ); if ( DestHelpFile == "HLP" ) { DestHelpFile = UserPath + szLaunch; if ( DoesFileExist( DestHelpFile, TRUE )) { if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"L' installation est terminΘe.\nVoulez vous parcourir le fichier\nd'aide maintenant?": "The installation is complete.\nDo you want to have a look at\nthe help file now?", Dialog1Title ,MB_YESNO | MB_ICONQUESTION ) == IDYES ) ::WinHelp( NULL, DestHelpFile, HELP_CONTENTS, 0L ); } } else { DestHelpFile = UserPath + szLaunch; if ( DoesFileExist( DestHelpFile, TRUE )) { if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"L' installation est terminΘe.\nVoulez vous lancer le programme maintenant?": "The installation is complete.\nDo you want to have a look at the program now?", Dialog1Title ,MB_YESNO | MB_ICONQUESTION ) == IDYES ) WinExec( DestHelpFile, SW_SHOW ); } } } }// Sucessful installation else { MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"L' installation est incomplΦte.\nPour utiliser ce produit, vous devrez l' installer α nouveau.": "Installation is not complete.\nPlease to use this program, install it again.", Dialog1Title, MB_OK | MB_ICONEXCLAMATION ); } END: PostMessage( WM_CLOSE ); return TRUE; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Implementation - Generic // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CSetupApp // Application implementation // // ---------------------------------------------------------- // Message MAP // ---------------------------------------------------------- BEGIN_MESSAGE_MAP(CSetupApp, CWinApp) //{{AFX_MSG_MAP(CSetupApp) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code ! //}}AFX_MSG_MAP // Standard file based document commands END_MESSAGE_MAP() // ---------------------------------------------------------- // Application instanciation // ---------------------------------------------------------- CSetupApp NEAR theApp; // ---------------------------------------------------------- // Instance Initialization // ---------------------------------------------------------- BOOL CSetupApp::InitInstance() { SetDialogBkColor(); // set dialog background color to gray EnableVBX(); // Initialize VBX support Ctl3dRegister( AfxGetInstanceHandle() ); // See CTL3D API UserConfigSize = 0L; // We need to retrieve the COMMAND line arguments if (m_lpCmdLine[0] != '\0') { ExtractParameter( m_lpCmdLine, (LPSTR)szOriginalPath, 1 ); ExtractParameter( m_lpCmdLine, (LPSTR)szTempSetupPath, 2 ); } else { ::MessageBox( NULL, "This program cannot be launched directly.\nSETUP.EXE must be used to to this.\n", Dialog1Title, MB_OK | MB_ICONSTOP ); return FALSE; } CFirst boite1; boite1.DoModal(); if ( bIsSetupOK ) { CMain MainBox; MainBox.DoModal(); } return TRUE; } // ---------------------------------------------------------- // Intance Exit ( like WEP ) // ---------------------------------------------------------- int CSetupApp::ExitInstance() { Ctl3dUnregister( AfxGetInstanceHandle() ); DeleteSystemDir( ); return CWinApp::ExitInstance(); } // ---------------------------------------------------------- // VBX Event MAP // ---------------------------------------------------------- //{{AFX_VBX_REGISTER_MAP() //}}AFX_VBX_REGISTER_MAP ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CFirst dialog - Splash style and initialization managment // // ---------------------------------------------------------- // Constructor // ---------------------------------------------------------- CFirst::CFirst(CWnd* pParent /*=NULL*/) : CDialog(CFirst::IDD, pParent) { //{{AFX_DATA_INIT(CFirst) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } // ---------------------------------------------------------- // Data Exchange // ---------------------------------------------------------- void CFirst::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CFirst) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } // ---------------------------------------------------------- // Message MAP // ---------------------------------------------------------- BEGIN_MESSAGE_MAP(CFirst, CDialog) //{{AFX_MSG_MAP(CFirst) ON_MESSAGE( PM_FIRST, OnFirstPrivate ) ON_WM_CLOSE() ON_WM_DESTROY() //}}AFX_MSG_MAP END_MESSAGE_MAP() // ---------------------------------------------------------- // WM_INITDIALOG // Interface managment and Call OnFirstPrivate // ---------------------------------------------------------- BOOL CFirst::OnInitDialog() { CDialog::OnInitDialog(); if ((hfontDlg = (HFONT) SendMessage(WM_GETFONT) )) { if (::GetObject(hfontDlg, sizeof(LOGFONT), (LPSTR) &lFont)) { lFont.lfWeight = FW_NORMAL; if (hfontDlg = CreateFontIndirect((LPLOGFONT) &lFont)) SendDlgItemMessage( IDC_STATIC1, WM_SETFONT, (WPARAM) hfontDlg, 0); } } SetWindowText( Dialog1Title ); SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) ); Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL ); CenterDialogBox( m_hWnd ); BringWindowToTop(); FirstCanClose = FALSE; PostMessage( PM_FIRST ); return TRUE; // return TRUE unless you set the focus to a control } // ---------------------------------------------------------- // PM_FIRST private message function // Guess the user Language // Set interface // Call SetupInitialize // ---------------------------------------------------------- afx_msg LRESULT CFirst::OnFirstPrivate( WPARAM wParam, LPARAM lParam ) { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// static char far szTemp[6]; // Have a look in WIN.INI for Language detection SendMessage( WM_PAINT ); GiveTheHand(); ::GetProfileString( "intl", "sLanguage", "", (LPSTR)szTemp, 4 ); AnsiUpper( szTemp ); if (lstrcmp( szTemp, "FRA" )== 0 ) iLanguage = LANGUAGE_FRENCH; else iLanguage = LANGUAGE_ENGLISH; bIsSetupOK = SetupInitialize( szYourName, szYourPassword, iLanguage, (LPSTR)szOriginalPath, (LPSTR)szTempSetupPath ); SetupSetTitle( szSetupBoxTitle ); GiveTheHand(); if ( bUseSharedBatch ) { CString szUserBatchFile, szUserBatchDir; GetWindowsDirectory( szUserBatchFile.GetBuffer(182), 180 ); szUserBatchFile.ReleaseBuffer(); szUserBatchFile = szUserBatchFile.Left( 3 ); szUserBatchDir = szUserBatchFile; szUserBatchFile += ( szBatchFile != "") ? szBatchFile : "SYSSETUP.TMP\\SYSSETUP.BAT" ; szUserBatchDir += ( szBatchDir != "")? szBatchDir : "SYSSETUP.TMP\\"; SetSharedBatchFile( szUserBatchFile, szUserBatchDir ); } SetPatternBrushStandard( iBackgroundPaper ); SetupSetBeepMode ( bBeepMode ); // Select or not the BEEP mode SetVerifyMode( bVerifyMode ); // Select or deselect the File Size Verification mode ( if size is bad, setup will abort ). // ---- panel 1 ---- if ( iPanel1Bitmap == 0 ) { if ( szPanel1Title.GetLength() > 0 ) { SetTextLogo( szPanel1Title, szPanel1TitleFont, iPanel1TitleSize, lPanel1TitleColor, bPanel1Title3D, bPanel1TitleBold ); if ( szPanel1Detail.GetLength() > 0 ) SetTextDetail( szPanel1Detail, szPanel1DetailFont, iPanel1DetailSize, lPanel1DetailColor, bPanel1Detail3D, bPanel1DetailBold ); SetLogoType( TRUE ); } } else { SetLogo( AfxGetInstanceHandle(), iPanel1Bitmap ); SetLogoType( FALSE ); } FirstCanClose = TRUE; PostMessage( WM_CLOSE ); return TRUE; } // ---------------------------------------------------------- // WM_CLOSE // Do not close during Initialization // ---------------------------------------------------------- void CFirst::OnClose() { if ( FirstCanClose ) // Disable user window closing during Initialisation.... CDialog::OnClose(); else MessageBeep( -1 ); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CMain dialog - In fact a pseudo dialog box only use with the ShowMainWindow CSETUP.DLL function // // ---------------------------------------------------------- // Constructor // ---------------------------------------------------------- CMain::CMain(CWnd* pParent /*=NULL*/) : CDialog(CMain::IDD, pParent) { //{{AFX_DATA_INIT(CMain) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } // ---------------------------------------------------------- // Data Exchange // ---------------------------------------------------------- void CMain::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMain) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } // ---------------------------------------------------------- // Message MAP // ---------------------------------------------------------- BEGIN_MESSAGE_MAP(CMain, CDialog) //{{AFX_MSG_MAP(CMain) ON_MESSAGE( PM_FIRST, OnFirstPrivate ) ON_MESSAGE( SN_NEWDISKREQUIRED, OnNewDisk ) ON_WM_PAINT() ON_WM_NCPAINT() //}}AFX_MSG_MAP END_MESSAGE_MAP() // ---------------------------------------------------------- // WM_INITDIALOG // Call CMain::OnFirstPrivate // ---------------------------------------------------------- BOOL CMain::OnInitDialog() { CDialog::OnInitDialog(); SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) ); SetWindowText( Dialog1Title ); BringWindowToTop(); PostMessage( PM_FIRST ); return TRUE; // return TRUE unless you set the focus to a control } // ---------------------------------------------------------- // SN_NEWDISKREQUIRED // You will receive this message // when CSetup shows the New Disk // Required dialog box. // ---------------------------------------------------------- afx_msg LRESULT CMain::OnNewDisk( WPARAM wParam, LPARAM lParam ) { return TRUE; }; // ---------------------------------------------------------- // WM_PAINT // Call ShowMainWindow CSETUP.DLL function // ---------------------------------------------------------- void CMain::OnPaint() { CPaintDC dc(this); RedrawWindow( NULL, NULL, RDW_NOFRAME | RDW_NOERASE ); // To prevent flashing ShowMainWindow( m_hWnd ); // The main function wich paint your window as a Setup Like window ( for PAINT ) RedrawWindow( NULL, NULL, RDW_NOFRAME | RDW_NOERASE ); // To prevent flashing } // ---------------------------------------------------------- // WM_PAINT // Call ShowMainWindow CSETUP.DLL function // ---------------------------------------------------------- void CMain::OnNcPaint() { RedrawWindow( NULL, NULL, RDW_NOERASE | RDW_VALIDATE ); // To prevent flashing ShowMainWindow( m_hWnd ); // The main function wich paint your window as a Setup Like window ( for PAINT ) RedrawWindow( NULL, NULL, RDW_NOERASE | RDW_VALIDATE ); // To prevent flashing } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CChoice1 dialog allows the user to choose Language and main Destination PATH // // ---------------------------------------------------------- // Constructor // ---------------------------------------------------------- CChoice1::CChoice1(CWnd* pParent /*=NULL*/) : CDialog(CChoice1::IDD, pParent) { //{{AFX_DATA_INIT(CChoice1) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } // ---------------------------------------------------------- // Data Exchange ( not used ) // ---------------------------------------------------------- void CChoice1::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CChoice1) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } // ---------------------------------------------------------- // Message MAP // ---------------------------------------------------------- BEGIN_MESSAGE_MAP(CChoice1, CDialog) //{{AFX_MSG_MAP(CChoice1) ON_BN_CLICKED(IDC_RADIOENGLISH, OnClickedRadioenglish) ON_BN_CLICKED(IDC_RADIOFRENCH, OnClickedRadiofrench) ON_EN_CHANGE(IDC_EDITSRCPATH, OnChangeEditsrcpath) ON_WM_DESTROY() //}}AFX_MSG_MAP END_MESSAGE_MAP() // ---------------------------------------------------------- // WM_COMMAND:ONLANGUAGE // Change the language // ---------------------------------------------------------- void CChoice1::OnClickedRadioenglish() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// SetupSetLanguage( LANGUAGE_ENGLISH ); iLanguage = LANGUAGE_ENGLISH; SetDlgItemText( IDC_GROUPLANGUAGE, "Your language "); CString ProductName; ProductName = ( iLanguage == LANGUAGE_FRENCH )? "Indiquer le rΘpertoire ou vous souhaitez installer ": "Please, give the directory in which you want to install "; ProductName += szProductName; ProductName += ( iLanguage == LANGUAGE_FRENCH )?" et cliquer sur OK:":" and click on OK"; SetDlgItemText( IDC_TEXTE, ProductName ); SetDlgItemText( IDCANCEL, "&Abort"); } // ---------------------------------------------------------- // WM_COMMAND:ONLANGUAGE // Change the language // ---------------------------------------------------------- void CChoice1::OnClickedRadiofrench() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// SetupSetLanguage( LANGUAGE_FRENCH ); iLanguage = LANGUAGE_FRENCH; SetDlgItemText( IDC_GROUPLANGUAGE, "Votre langage "); CString ProductName; ProductName = ( iLanguage == LANGUAGE_FRENCH )? "Indiquer le rΘpertoire ou vous souhaitez installer ": "Please, give the directory in which you want to install "; ProductName += szProductName; ProductName += ( iLanguage == LANGUAGE_FRENCH )?" et cliquer sur OK:":" and click on OK"; SetDlgItemText( IDC_TEXTE, ProductName ); SetDlgItemText( IDCANCEL, "&Abandonner"); } // ---------------------------------------------------------- // WM_COMMAND:ONPATH // Change the path // ---------------------------------------------------------- void CChoice1::OnChangeEditsrcpath() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// CString TempDestName; GetDlgItemText( IDC_EDITSRCPATH, TempDestName.GetBuffer( 162 ), 160 ); TempDestName.ReleaseBuffer(); if ( TempDestName.GetLength() < 1 ) GetDlgItem( IDOK)->EnableWindow( FALSE ); else GetDlgItem( IDOK)->EnableWindow( TRUE ); } // ---------------------------------------------------------- // WM_COMMAND:ONOK // Check the path thanks to // CSETUP functions // ---------------------------------------------------------- void CChoice1::OnOK() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// CString TempDestName; GetDlgItemText( IDC_EDITSRCPATH, TempDestName.GetBuffer(162), 160 ); TempDestName.ReleaseBuffer(); if ( !IsFileName( TempDestName, FILENAME_DIRWITHSLASH, CHECK_ROOTDIRSEXIST) ) { TempDestName = FormatFileNameValid( TempDestName, TRUE); SetDlgItemText( IDC_EDITSRCPATH, TempDestName ); } if ( IsFileName( TempDestName, FILENAME_DIRWITHSLASH, CHECK_ROOTDIRSEXIST) ) { UserPath = TempDestName; CDialog::OnOK(); } else { MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"Le rΘpertoire mentionnΘ n' est pas valide.\nSi vous avez mentionnΘ des sous rΘpertoires\nceux ci doivent exister.\n": "Directory name is not valid.\nIf you want to specifie sub directories\nthey must exist.\n", Dialog1Title, MB_OK | MB_ICONEXCLAMATION ); (CEdit*)(GetDlgItem( IDC_EDITSRCPATH))->SetFocus(); ((CEdit*)(GetDlgItem( IDC_EDITSRCPATH)))->SetSel( 0, -1 ); } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CChoice2 dialog allows the user to select files to install // // ---------------------------------------------------------- // Constructor // ---------------------------------------------------------- CChoice2::CChoice2(CWnd* pParent /*=NULL*/) : CDialog(CChoice2::IDD, pParent) { //{{AFX_DATA_INIT(CChoice2) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } // ---------------------------------------------------------- // Data Exchange ( Not use ) // ---------------------------------------------------------- void CChoice2::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CChoice2) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } // ---------------------------------------------------------- // Message MAP // ---------------------------------------------------------- BEGIN_MESSAGE_MAP(CChoice2, CDialog) //{{AFX_MSG_MAP(CChoice2) ON_BN_CLICKED(IDB_CHANGEPATH, OnClickedChangepath) ON_BN_CLICKED(IDC_CHECK1, OnClickedCheck1) ON_BN_CLICKED(IDC_CHECK2, OnClickedCheck2) ON_BN_CLICKED(IDC_CHECK3, OnClickedCheck3) ON_BN_CLICKED(IDC_CHECK4, OnClickedCheck4) ON_BN_CLICKED(IDC_CHECK5, OnClickedCheck5) ON_BN_CLICKED(IDC_CHECK6, OnClickedCheck6) ON_BN_CLICKED(IDC_CHECK7, OnClickedCheck7) ON_BN_CLICKED(IDC_CHECK8, OnClickedCheck8) ON_BN_CLICKED(IDC_CHECK9, OnClickedCheck9) ON_BN_CLICKED(IDC_CHECK10, OnClickedCheck10) ON_BN_CLICKED(IDC_CHECK11, OnClickedCheck11) ON_BN_CLICKED(IDC_CHECK12, OnClickedCheck12) ON_BN_CLICKED(IDC_CHECK13, OnClickedCheck13) ON_BN_CLICKED(IDC_CHECK14, OnClickedCheck14) ON_BN_CLICKED(IDC_CHECK15, OnClickedCheck15) ON_WM_DESTROY() //}}AFX_MSG_MAP END_MESSAGE_MAP() // ---------------------------------------------------------- // WM_INITDIALOG // Check boxes managment // ---------------------------------------------------------- BOOL CChoice2::OnInitDialog() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// register int i=0; CDialog::OnInitDialog(); SetWindowText( Dialog3Title ); if ((hfontDlg = (HFONT) SendMessage(WM_GETFONT) )) { if (::GetObject(hfontDlg, sizeof(LOGFONT), (LPSTR) &lFont)) { lFont.lfWeight = FW_NORMAL; if (hfontDlg = CreateFontIndirect((LPLOGFONT) &lFont)) { SendDlgItemMessage( IDC_CHECK1, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK2, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK3, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK4, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK5, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK6, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK7, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK8, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK9, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK10, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK11, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK12, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK13, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK14, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK15, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K1, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K2, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K3, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K4, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K5, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K6, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K7, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K8, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K9, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K10, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K11, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K12, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K13, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K14, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K15, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_GROUP, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_TEXTECSIZE, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_KCONFIG, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_TEXTETOTALSIZE, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_KTOTAL, WM_SETFONT, (WPARAM) hfontDlg, 0); } } } // We resize the dialog box depending of number of items RECT r, r2, r3; GetWindowRect( &r3 ); GetDlgItem( IDC_CHECK1 )->GetWindowRect( &r2 ); GetDlgItem( IDC_GROUP )->GetWindowRect( &r ); GetDlgItem( IDC_GROUP )->SetWindowPos( NULL, 0,0, r.right-r.left, r.bottom - ( ((15- NumberOfSections)<9?15- NumberOfSections:9 ) * (r2.bottom-r2.top) )-r.top-12, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE ); GetDlgItem( IDC_TEXTECSIZE )->GetWindowRect( &r ); GetDlgItem( IDC_TEXTECSIZE )->SetWindowPos( NULL, r.left - r3.left, r.top -( ( (16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top-20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE ); GetDlgItem( IDC_KCONFIG )->GetWindowRect( &r ); GetDlgItem( IDC_KCONFIG )->SetWindowPos( NULL, r.left- r3.left, r.top -( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top -20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE ); GetDlgItem( IDC_TEXTETOTALSIZE )->GetWindowRect( &r ); GetDlgItem( IDC_TEXTETOTALSIZE )->SetWindowPos( NULL, r.left- r3.left, r.top -( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top -20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE ); GetDlgItem( IDC_KTOTAL )->GetWindowRect( &r ); GetDlgItem( IDC_KTOTAL )->SetWindowPos( NULL, r.left- r3.left, r.top -( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top -20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE ); SetWindowPos( NULL, 0,0, r3.right-r3.left, r3.bottom - ( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top+20, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE ); // Set the dialog box value CString TempLabel; UserConfigSize = 0L; for ( i = 0 ; i < NumberOfSections ; i++ ) { if ( Section[i].Name.GetLength()> 0 ) { TempLabel = ( iLanguage == LANGUAGE_FRENCH)?Section[i].FLabel : Section[i].ELabel; if ( TempLabel.GetLength() > 0 ) { GetDlgItem( 120 + i )->ShowWindow( SW_SHOW ); GetDlgItem( 150 + i )->ShowWindow( SW_SHOW ); SetDlgItemText( 120 + i, TempLabel ); // --> label CheckDlgButton( 120 + i, Section[i].bSelected ); if ( Section[i].bSelected ) { UserConfigSize += Section[i].lSize; _ltoa( UserConfigSize, TempLabel.GetBuffer(12), 10 ); TempLabel.ReleaseBuffer(); TempLabel += " K"; SetDlgItemText( IDC_KCONFIG, TempLabel ); _ltoa( Section[i].lSize, TempLabel.GetBuffer(10), 10 ); TempLabel.ReleaseBuffer(); } else TempLabel = "0"; TempLabel += " K"; SetDlgItemText( 150 + i, TempLabel ); } } } SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) ); Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL ); CenterDialogBox( m_hWnd ); BringWindowToTop(); if ( iLanguage == LANGUAGE_FRENCH ) { SetDlgItemText( IDC_GROUP, "Installer... "); SetDlgItemText( IDC_TEXTECSIZE, "Taille de la sΘlection:"); SetDlgItemText( IDC_TEXTETOTALSIZE, "Espace disponible:"); SetDlgItemText( IDB_CHANGEPATH, "&RΘpertoire..."); SetDlgItemText( IDOK, "OK" ); SetDlgItemText( IDCANCEL, "Aba&ndonner" ); } _ltoa( AskForDriveSpace( GetDriveNumber( UserPath )), TempLabel.GetBuffer(15), 10 ); TempLabel.ReleaseBuffer(); TempLabel += " K"; SetDlgItemText( IDC_KTOTAL, TempLabel ); GetDlgItem( IDC_CHECK1 )->SetFocus(); return FALSE; } // ---------------------------------------------------------- // WM_COMMAND:ONPATH // Save the configuration and // Call the CChoice1 Dialog box // ---------------------------------------------------------- void CChoice2::OnClickedChangepath() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// register int i = 0; for ( i = 0 ; i < NumberOfSections ; i++ ) Section[i].bSelected = IsDlgButtonChecked( 120 + i ); EndDialog( IDCHANGEPATH ); } // ---------------------------------------------------------- // WM_COMMAND:ONOK // Check available disk size // ---------------------------------------------------------- void CChoice2::OnOK() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// register int i = 0; if ( UserConfigSize > AskForDriveSpace( GetDriveNumber( UserPath )) ) { if ( iLanguage == LANGUAGE_FRENCH ) MessageBox("Il n' y a pas assez d' espace libre\nsur l' unitΘ destination pour installer\nla sΘlection que vous avez choisie.\n\nVeuillez modifier votre sΘlection ou changer de rΘpertoire." , Dialog1Title, MB_OK | MB_ICONEXCLAMATION ); else MessageBox("There is not enough free space\nto install selected files.\n\nPlease, change your selection or the destination directory." , Dialog1Title, MB_OK | MB_ICONEXCLAMATION ); } else CDialog::OnOK(); } /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// // ---------------------------------------------------------- // WM_COMMAND:ONCHECKxx ? // Check Box management // ---------------------------------------------------------- void CChoice2::OnClickedCheck1() { HandleCheckBox( 1 ); } void CChoice2::OnClickedCheck2() { HandleCheckBox( 2 ); } void CChoice2::OnClickedCheck3() { HandleCheckBox( 3 ); } void CChoice2::OnClickedCheck4() { HandleCheckBox( 4 ); } void CChoice2::OnClickedCheck5() { HandleCheckBox( 5 ); } void CChoice2::OnClickedCheck6() { HandleCheckBox( 6 ); } void CChoice2::OnClickedCheck7() { HandleCheckBox( 7 ); } void CChoice2::OnClickedCheck8() { HandleCheckBox( 8 ); } void CChoice2::OnClickedCheck9() { HandleCheckBox( 9 ); } void CChoice2::OnClickedCheck10() { HandleCheckBox( 10 ); } void CChoice2::OnClickedCheck11() { HandleCheckBox( 11 ); } void CChoice2::OnClickedCheck12() { HandleCheckBox( 12 ); } void CChoice2::OnClickedCheck13() { HandleCheckBox( 13 ); } void CChoice2::OnClickedCheck14() { HandleCheckBox( 14 ); } void CChoice2::OnClickedCheck15() { HandleCheckBox( 15 ); } void CChoice2::HandleCheckBox( int iD ) { CString Temp; if ( IsDlgButtonChecked( 120 + iD - 1 )) { UserConfigSize += Section[iD - 1].lSize; _ltoa( Section[iD - 1].lSize, Temp.GetBuffer( 12 ), 10 ); Temp.ReleaseBuffer(); Temp += " K"; SetDlgItemText( 150 + iD-1 , Temp ); Section[iD - 1].bSelected = TRUE; } else { UserConfigSize -= Section[iD - 1].lSize; SetDlgItemText(150 + iD-1, "0 K" ); Section[iD - 1].bSelected = FALSE; } _ltoa( UserConfigSize, Temp.GetBuffer( 12 ), 10 ); Temp.ReleaseBuffer(); Temp += " K"; SetDlgItemText( IDC_KCONFIG, Temp ); } void CChoice2::OnDestroy() { CDialog::OnDestroy(); ::DeleteObject( hfontDlg ); } void CChoice1::OnDestroy() { CDialog::OnDestroy(); ::DeleteObject( hfontDlg ); } void CFirst::OnDestroy() { CDialog::OnDestroy(); ::DeleteObject( hfontDlg ); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Local functions // ---------------------------------------------------------- // ExtractParameter( LPSTR, Buffer, position ) // Extract the Command line parameters // ---------------------------------------------------------- BOOL ExtractParameter( LPSTR szCommandLine, LPSTR szBuffer, int position ) { LPSTR szTemp; LPSTR pos; LPSTR szStart= "0000"; LPSTR szStop = "00000"; BOOL test1 = FALSE; BOOL test2 = FALSE; HANDLE h1; char Mask =' ' ; int i; if ( (szBuffer == (LPSTR)NULL) || (szCommandLine == (LPSTR)NULL) ) return FALSE; h1 = GlobalAlloc( LHND,(long) (lstrlen( szCommandLine ) + 3 ) ); szTemp = (LPSTR)GlobalLock(h1); lstrcpyn( szStart, szCommandLine, 2); if ( lstrcmp( szStart, " " ) == 0 ) test1 = TRUE; lstrcpyn( szStop, szCommandLine+ lstrlen( szCommandLine) - 1 , 2 ); if ( lstrcmp( szStop, " ") != 0 ) test2 = TRUE; if ( (test1) && (test2)) { lstrcpy( szTemp, szCommandLine+1); lstrcat( szTemp, " "); } else { if ( test1 ) lstrcpy( szTemp, szCommandLine+1 ); if ( test2 ) { lstrcpy( szTemp, szCommandLine ); lstrcat( szTemp, " "); } if ( (!test1) && (!test2)) lstrcpy( szTemp, szCommandLine); } i=1; for ( i=1; i <= position ; i++ ) { pos = (LPSTR)_fmemchr(szTemp, ' ', lstrlen(szTemp) ); if ( (i== position) && ( (pos != NULL) || ( position == 1))) { lstrcpyn(szBuffer, szTemp, (pos-szTemp)+1); GlobalUnlock( h1 ); GlobalFree( h1 ); return TRUE; } else { if ( pos != NULL ) lstrcpy( szTemp, _fstrstr(szTemp," ")+1); else lstrcpy( szTemp, ""); } } lstrcpy( szBuffer, ""); GlobalUnlock( h1 ); GlobalFree( h1 ); return FALSE; } //////////////////////////////////////////////// END OF THIS FILE ////////////////////////////////////////////////////////////////